#ifndef URL_H_INCLUDED
#define URL_H_INCLUDED

#ifdef __cplusplus
extern "C"
{
#endif

#include "common.h"

//------------------------------------------------------------------------------
// typedefs
//------------------------------------------------------------------------------

/**
 * @enum httpheader_t
 *       This enum is for extracting only required data from the received HTTP
 *       headers.
 */
typedef enum httpheader
{
    HTTP_STATUS_CODE_REQUIRED    = 0,
    HTTP_CONTENT_LENGTH_REQUIRED = 1,
    HTTP_NO_INFO_REQUIRED        = 2
} httpheader_t;

//------------------------------------------------------------------------------
// enums
//------------------------------------------------------------------------------

enum
{
    RESPONSE_HTTP_ERROR = 400
};

enum
{
    URL_SIZE = 256
};

//------------------------------------------------------------------------------
// structs
//------------------------------------------------------------------------------

/**
 * @struct memory_t
 *         This struct provides all the parameters for the "get to memory"
 *         operations.
 * @note if predicate function pointer is not NULL, it is called regularly!
 */
typedef struct memory
{
    const char*   url;                ///< url to be retrieved
    char*         retrieved;          ///< allocated memory to store the data retrieved
    size_t        size;               ///< memory size
    httpheader_t  header_info;
    int           content_length;
} memory_t;

//------------------------------------------------------------------------------
// functions
//------------------------------------------------------------------------------

bool
URL_DownloadToMemory(memory_t* a_memory, int a_timeout_connection, int a_timeout);

#ifdef __cplusplus
}
#endif

#endif // URL_H_INCLUDED
